package edu.chinasoft.servlet;

import java.io.IOException;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.annotation.WebServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import edu.chinasoft.domain.Function;
import edu.chinasoft.service.FunctionService;

/**
 *
 * @author mhao
 * @date 2020年2月12日:下午3:56:48
 * @version V1.0
 * @Description: 
*/
@WebServlet(name = "myAllFatherFunctionServlet", value = "/servlet/allfatherfunctionservlet")
public class AllFatherFunctionServlet extends HttpServlet {
	private static Logger logger = LoggerFactory.getLogger(AllFatherFunctionServlet.class);
	private FunctionService functionService;
	/**
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.info(" AllFatherFunctionServlet >doGet start.......");
		WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
		FunctionService functionServiceImp = wac.getBean("functionService", FunctionService.class);
		this.functionService=functionServiceImp;
		List<Function> functionList = functionService.selectFatherFunction();
		HttpSession session = request.getSession();
		session.setAttribute("allFatherFunction", functionList);
		response.sendRedirect(request.getContextPath()+"/addFunction.jsp?key01"+new Date().getTime());
		logger.info(" AllFatherFunctionServlet >doGet end.......");
	}

	/**
	 *
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		logger.info(" AllFatherFunctionServlet >doPost start.......");
		this.doGet(request, response);
		logger.info(" AllFatherFunctionServlet >doPost end.......");
	}

}